home *** CD-ROM | disk | FTP | other *** search
- Path: katie.vnet.net!not-for-mail
- From: gregg@katie.vnet.net (gregg)
- Newsgroups: comp.lang.c++
- Subject: Re: Linking, Libraries and Static memebers
- Date: 31 Jan 1996 13:01:32 -0500
- Organization: Vnet Internet Access, Charlotte, NC - info@char.vnet.net
- Message-ID: <4eoaps$j61@katie.vnet.net>
- References: <4elglh$i1l@katie.vnet.net>
- NNTP-Posting-Host: katie.vnet.net
-
- gregg@katie.vnet.net (gregg) writes:
-
- Whoops! My example code wasn't quite what I had in mind. Here's the
- correction.
-
- I've got a class that has some static members, which I've compiled
- into a library. When I try to use those static members in an
- application that links in that library, the static members haven't
- been initialized!
-
- //(The RW prefixed objects are Rouge Wave objects)
-
- //file Foo.hpp
- class Foo
- {
- public:
- static RWCString a_string;
- }
-
- //file Foo.cpp
- #include "Foo.hpp"
-
- RWCString Foo::a_string = "Initial Value"
-
- //Foo.cpp is compiled into a library called Foo.lib.
-
- //file App.cpp
- #include <iostream.h>
- #include "Foo.hpp"
-
- class Bar
- {
- static RWCString another_string;
- }
-
- RWCString Bar::another_string = Foo::a_string;
-
- main ()
- {
- cout << Bar::another_string;
- }
-
-
- When I run App, I get a null value coming out. What am I not doing?
- I am using MSVC 4.0 under Windows NT.
-
- Also, If I run the debugger, on the Bar::another_string assignment
- line, Foo::a_string is null.
-
- Thanks. Again.
-
- -Greg G
-